<?php

use yii\db\Migration;

/**
 * Handles the creation of table `activity`.
 */
class m180516_064022_create_activity_table extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function up()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE=InnoDB';
        }
        $this->createTable('{{%activity}}', [
            'id' => $this->primaryKey(),
            'name' => $this->string(255)->notNull()->comment("活动名称"),
            'banner'=>$this->string(255)->comment('banner'),
            'other_entry'=>$this->string(255)->comment('其他活动入口'),
            'other_entry_url'=>$this->string(255)->comment('活动链接'),

            'activity_catalog'=>$this->smallInteger()->defaultValue(0)->comment("活动类型"),
            'peoples'=>$this->smallInteger()->comment('组团人数'),

            'start_user_type'=>$this->smallInteger()->comment('开团用户类型 1全部 2新用户 3老用户'),
            'join_user_type'=>$this->smallInteger()->comment('参团用户类型 1全部 2新用户 3老用户'),
            'start_time' => $this->dateTime()->notNull()->comment("开始时间"),
            'end_time' => $this->dateTime()->notNull()->comment('结束时间'),


            'goods' => $this->text()->comment('商品编号'),
            'description'=>$this->text()->comment('活动说明'),
            'store_id'=>$this->string(255)->comment('StoreId'),
            'status' => $this->smallInteger(1)->defaultValue(1)->comment('1:未开始 2:进行中 3:已抢光')
        ], $tableOptions);
        return true;
    }

    /**
     * {@inheritdoc}
     */
    public function down()
    {
        $this->dropTable('{{%activity}}');
        return true;
    }
}
